// pages/order/logistics/logistics.js
//pages/order/logistics/logistics?orderId=xx

var httpUtil = require('../../../utils/httpUtil.js')
var uiUtil = require('../../../utils/uiUtil.js')
var util = require('../../../utils/util.js')
var emptyUtil = require('../../templates/empty/empty.js')
var that

Page({

  /**
   * 页面的初始数据
   */
  data: {
    dataList: null,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    that = this
    var orderId = options.orderId
    if (orderId) {
      this.requestDeleteOrder(orderId)
    }
  },
  onShareAppMessage: function (res) {
    return util.handleShareApp()
  },
  /**
   * 联系客服点击
   */
  onContactClick(e) {
    var phoneNo = e.currentTarget.dataset.phoneno;
    if (phoneNo) {
      wx.makePhoneCall({
        phoneNumber: phoneNo,
      })
    }
  },

  /**
   * 获取删除订单
   */
  requestDeleteOrder(orderId) {
    uiUtil.showLoading("请稍候..")
    httpUtil.PostRequest("order_logistics", {
      orderId: orderId
    }, {
      success(res) {
        var list = res || []
        if (list.length == 0) {
          emptyUtil.showEmptyView()
        } else {
          that.setData({
            dataList: list
          })
        }
      },
      fail(code, res) {
        var text = emptyUtil.getErrText(code, res, "获取物流信息失败")
        emptyUtil.showFailView(text)
      },
      complete() {
        uiUtil.hideLoading()
      }
    })
  },

})
